home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13461 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.0 KB  |  62 lines

  1. Newsgroups: comp.lang.c++
  2. Path: artemis.sto.fdata.se!news
  3. From: Niklas Mellin <niklas.mellin@sto.fdata.se>
  4. Subject: Re: Default Class Initialisation Question...
  5. Sender: news@artemis.sto.fdata.se (UseNet NetNews)
  6. Message-ID: <3156D1BF.36E9@sto.fdata.se>
  7. Date: Mon, 25 Mar 1996 17:02:55 GMT
  8. Content-Transfer-Encoding: 7bit
  9. Content-Type: text/plain; charset=us-ascii
  10. References: <00001a81+0000af6f@msn.com> <4j57mv$6ps@park.interport.net>
  11. Mime-Version: 1.0
  12. X-Mailer: Mozilla 2.0 (WinNT; I)
  13. Organization: WM-data F÷rsvarsdata AB, Sweden
  14.  
  15. Adi wrote:
  16. > Tony_Bateman@msn.com (Tony Bateman) wrote:
  17. > >I have a problem concerning default initialisation of classes.
  18. > >If I define a class Rectangle, and have default initialisation values
  19. > >in the constructor defined thus:
  20. > >Rectangle::Rectangle(USHORT width=0, USHORT height=0):
  21. > >itsWidth(width),
  22. > >itsHeight(height)
  23. > >{}
  24. > >then I can define a rectangle to have a width = 30 and height = 0 by
  25. > >omitting one of the variables in the initialisation:
  26. > >Rectangle myRectangle(30);
  27. > >Fine. But what if I want to leave the width a default value of 0 and
  28. > >set the height to 30. How could I do it? Can it be done in C++ in a
  29. > >straightforward manner? Is there anything like a default placeholder
  30. > >that can be used?
  31. > >               Regards,
  32. > >                       Tony Bateman.
  33. > >-----------------------------------------------------------------------------
  34. > >I live in Finland - second highest suicide rate per head of
  35. > >population in the world.
  36. > >It's the beginning of spring - most common time for suicides.
  37. > >Computer programmering is a recognised high risk suicide profession.
  38. > >Do NOT spill my pint.....
  39. > >-----------------------------------------------------------------------------
  40. > >
  41. > Just forget about it. There is no such thing in the C++ syntax.
  42. > Annoying, ahha...
  43. > Adi Degani
  44. > New-York, NY
  45.  
  46. Bjarne Stroustrup mention this in his book: "The Design and Evolution of C++"
  47. and explains why it is done the way it is.
  48.  
  49. ---
  50. Niklas Mellin
  51.